package com.zretc.service.impl;

import com.zretc.dao.SellerMapper;
import com.zretc.entity.Seller;
import com.zretc.service.SellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private SellerMapper sellerMapper;

    @Override
    public Seller login(String sellerAccount, String sellerPassword) {
        return sellerMapper.getSellerByIdAndPassword(sellerAccount,sellerPassword);
    }

    @Override
    public int register(Seller seller) {
        return sellerMapper.setSeller(seller);
    }

    @Override
    public Seller update(Map<String, Object> param) {
        Integer up = sellerMapper.updateBySellerId(param);
        if (up == 0){
            return null;
        }else {

            String sellerAccount = (String) param.get("sellerAccount");
            return sellerMapper.getSeller(sellerAccount);
        }

    }

    @Override
    public Seller judgeExist(String sellerAccount) {
        return sellerMapper.getSeller(sellerAccount);
    }
}
